/**
File Name 	: MDateTime.c
Name, NIM	: Muqtafi Akhmad, 23512021
 **/

#include <stdio.h>
#include <stdlib.h>
#include "DateTime.h"

int main(int argc, char** argv) {
    // Kamus
    int YY, MM, DD, hour, min, sec;
    DateTime dt1, dt2;
    // Algoritma
    printf("input date time pertama hingga valid (YYYY-MM-DD hour:min:sec) \n");
    scanf("%d-%d-%d %d:%d:%d", &YY, &MM, &DD, &hour, &min, &sec);
    while (!IsValidDateTime(YY, MM, DD, hour, min, sec)) {
        printf("Date time tidak valid, silakan input kembali \n");
        scanf("%d-%d-%d %d:%d:%d", &YY, &MM, &DD, &hour, &min, &sec);
    }
    dt1 = MakeDateTime(YY, MM, DD, hour, min, sec);

    printf("input date time kedua hingga valid (YYYY-MM-DD hour:min:sec) \n");
    scanf("%d-%d-%d %d:%d:%d", &YY, &MM, &DD, &hour, &min, &sec);
    while (!IsValidDateTime(YY, MM, DD, hour, min, sec)) {
        printf("Date time tidak valid, silakan input kembali \n");
        scanf("%d-%d-%d %d:%d:%d", &YY, &MM, &DD, &hour, &min, &sec);
    }
    dt2 = MakeDateTime(YY, MM, DD, hour, min, sec);

    if (DateTimeLessThan(dt1, dt2)) {
        printf("DT1 < DT2 \n");
    } else {
        printf("DT1 > DT2 \n");
    }
    
    printf("Test parsing string ke date time dan sebaliknya \n");
    char* input = "2012-09-09 10:10:44";
    DateTime dtn = ParseDateTime(input);
    PrintDateTime(dtn);
    
    printf("\n %s \n", DateTimeToString(dtn));
    
    return (EXIT_SUCCESS);
}

